﻿<Window x:Class="Samcrypt.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="398" Width="553">
    <Grid>
        
        <Grid.Resources>
            <!--<Style  TargetType="{x:Type TextBox}">
                <Setter Property="AcceptsReturn" Value="true" />
                <Setter Property="TextWrapping" Value="Wrap" />
                <Setter Property="Text" Value="Hello World 1. This is a test of the emergancy brodacast sysetm." />
            </Style>-->



            <Style x:Key="itemsControlStyle1" TargetType="{x:Type ItemsControl}">
                <Setter Property="ItemsSource" Value="{Binding Path=Document.Pages}" />
                <Setter Property="ItemTemplate" >
                    <Setter.Value>
                        <DataTemplate>

                            <Grid Name="documentGrid" Grid.Column="0" Margin="15,10,15,5">

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="60" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>

                                <Border Name="docHeaderBorder" Grid.Row="0" BorderBrush="Black" BorderThickness="1,1,1,0" CornerRadius="5,5,0,0"
                        Background="{StaticResource docHeaderBackground}"
                        HorizontalAlignment="Left"
                        >


                                    <Grid Name="docHeaderGrid" MaxWidth="500"  >
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition  Width="*" MinWidth="200"  />

                                            <ColumnDefinition  Width="Auto" />
                                        </Grid.ColumnDefinitions>

                                        <Border Name="docTitleBorder" Grid.Column="0" VerticalAlignment="Center"  Padding="4,0,4,1" Margin="15,0,6,0" 
                                
                                           
                                        Style="{StaticResource docTitleBorderStyle1}"
                                        >
                                            <TextBox x:Name="textBox2"  FontSize="17"  Background="Transparent" BorderBrush="Transparent"
                                                 Text="{Binding Path=Title, UpdateSourceTrigger=PropertyChanged}" 
                                                 SpellCheck.IsEnabled="{Binding ElementName=spellingCheckBox, Path=IsChecked}"
                                                 />
                                        </Border>

                                        <StackPanel Name="docDateTimePanel" Grid.Column="2" 
                                    VerticalAlignment="Center"  HorizontalAlignment="Right"
                                    Margin="20,0,0,0"
                                            >
                                            <TextBlock Margin="0,4,15,0" 
                                               Text="{Binding Path=LastModifed, 
                                               Converter={StaticResource formatter}, ConverterParameter=' \{0:MMMM d, yyyy\}'}" 
                                               Style="{StaticResource docDateTimeStyle1}"/>
                                            <TextBlock Margin="0,0,15,0" 
                                               Text="{Binding Path=LastModifed, 
                                               Converter={StaticResource formatter}, ConverterParameter=' \{0:h:mm tt\}'}"
                                               Style="{StaticResource docDateTimeStyle1}"/>
                                        </StackPanel>
                                    </Grid>

                                </Border>

                                <Border Grid.Row="1"  BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="0,5,5,5" Padding="5"
                        MinHeight="100">

                                    <TextBox x:Name="docBodyTextBox"  AcceptsReturn="True" 
                                         VerticalScrollBarVisibility="Disabled"  
                                         HorizontalScrollBarVisibility="Disabled"
                                     Margin="1,0,0,0"
                                        Text="{Binding Path=Text, UpdateSourceTrigger=PropertyChanged}"
                                     
                                     TextWrapping="NoWrap"
                                     FontSize="14" FontFamily="Courier New"
                                     SpellCheck.IsEnabled="{Binding ElementName=spellingCheckBox, Path=IsChecked}"
                                         
                                     
                                             
                                     >

                                    </TextBox>

                                </Border>

                                <GridSplitter Name="docHeaderSplitter" Grid.Row="0" Background="Transparent" Height="3" 
                                      HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />

                            </Grid>


                        </DataTemplate>
                    </Setter.Value>
                    
                </Setter>
                
            </Style>


            <Style x:Key="LeftScrollViewer" TargetType="{x:Type ScrollViewer}">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollViewer}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <ScrollContentPresenter Grid.Column="1"/>

                                <ScrollBar Name="PART_VerticalScrollBar"
            Value="{TemplateBinding VerticalOffset}"
            Maximum="{TemplateBinding ScrollableHeight}"
            ViewportSize="{TemplateBinding ViewportHeight}"
            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                                <ScrollBar Name="PART_HorizontalScrollBar"
            Orientation="Horizontal"
            Grid.Row="1"
            Grid.Column="1"
            Value="{TemplateBinding HorizontalOffset}"
            Maximum="{TemplateBinding ScrollableWidth}"
            ViewportSize="{TemplateBinding ViewportWidth}"
            Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>

                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>


        </Grid.Resources>



        <ScrollViewer Name="scrollViewer1" HorizontalScrollBarVisibility="Auto" CanContentScroll="True" Style="{DynamicResource LeftScrollViewer}" >

                    <ItemsControl Style="{DynamicResource itemsControlStyle1}" />
            
        </ScrollViewer>








    </Grid>
</Window>
